package cn.devices.service.impl;

import cn.devices.dto.DeviceDto;
import cn.devices.dto.TaskDto;
import cn.devices.entity.TbTask;
import cn.devices.mapper.TbTaskMapper;
import cn.devices.service.TbTaskService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 设备盘点任务表 服务实现类
 * </p>
 *
 * @author 秋水浮萍
 * @since 2021-02-07
 */
@Service
public class TbTaskServiceImpl implements TbTaskService {

    @Autowired
    private TbTaskMapper tbTaskMapper;

    @Override
    public int taskAdd(TbTask tbTask) {
        return tbTaskMapper.taskAdd(tbTask);
    }

    @Override
    public int taskUpdate(TbTask tbTask) {
        return tbTaskMapper.taskUpdate(tbTask);
    }

    @Override
    public int taskDelete(String taskId) {
        return tbTaskMapper.taskDelete(taskId);
    }

    @Override
    public TaskDto taskDto2(String taskId) {
        return tbTaskMapper.taskDto2(taskId);
    }

    @Override
    public TaskDto taskDto() {
        return tbTaskMapper.taskDto();
    }

    @Override
    public PageInfo<TbTask> tbTaskList(int pageIndex, int pageSize) {
        PageHelper.startPage(pageIndex, pageSize);
        List<TbTask> tbTaskList = tbTaskMapper.tbTaskList();
        return new PageInfo<>(tbTaskList);
    }

    @Override
    public List<TbTask> getByTaskList() {
        return tbTaskMapper.tbTaskList();
    }

    @Override
    public TbTask tbTaskById(String taskId) {
        return tbTaskMapper.tbTaskById(taskId);
    }

    @Override
    public List<DeviceDto> deviceDtoList1(String taskId) {

        List<DeviceDto> list = tbTaskMapper.deviceDtoList1(taskId);
        for (DeviceDto dto : list
        ) {
            dto.setMessage("未扫描到");
        }
        return list;
    }

    @Override
    public List<DeviceDto> deviceDtoList2(String taskId) {
        List<DeviceDto> list = tbTaskMapper.deviceDtoList2(taskId);

        return list;
    }

    @Override
    public List<DeviceDto> deviceDtoList3(String taskId) {
        return tbTaskMapper.deviceDtoList3(taskId);
    }
}
